package collection;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;

public class GenericDemo  {
    public static void main(String[] args) {
        Collection<String> c=new ArrayList<>();
        c.add("one");
        c.add("two");
        c.add("three");
        c.add("four");
        c.add("five");
        Iterator<String> it=c.iterator();
        while (it.hasNext()){
            String str= it.next();
            System.out.println(str);
        }
        for (String str1:c){
            System.out.println(str1);
        }
        Collection<Point> o1=new ArrayList<>();
        o1.add(new Point(1,2));
        o1.add(new Point(3,4));
        o1.add(new Point(5,6));
        Iterator<Point> t= o1.iterator();
        while (t.hasNext()){
            Point p=t.next();
            System.out.println(p);
        }
        for (Point p:o1){
            System.out.println(p);
        }
    }
}
